package me.keiwu.admin.util;

import me.keiwu.admin.domain.system.SysUser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * Created by kei on 07/08/2017.
 */
public class UserUtil {

    public static SysUser getLoginUser() {
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        if (auth != null && auth.getPrincipal() != null) {
            return (SysUser) auth.getPrincipal();
        }
        return null;
    }


}
